package com.srcptit.trainning.tranquangvinh.b1;

import java.util.Scanner;

public class Bai2UCLN {
	public static int UCLN(int a,int b) {
		while(a!=0 && b!=0){
			if(a>=b) a=a%b;
			else b=b%a;
		}
		return (a+b);
	}
	public static  void main(String[] args) {
		int a,b;
		Scanner sc= new Scanner(System.in) ;
		System.out.println("Nhap so nguyen a:");
		a=sc.nextInt();
		System.out.println("Nhap so nguyen b:");
		b=sc.nextInt();
		System.out.println("Uoc chung lon nhat cua "+a+" va "+b+" la: "+ UCLN(a,b));
	}
}
